Language Elements and Expressions > Expressions > Operator Precedence

Operator Precedence

As in conventional mathematics, ProModel evaluates expressions with more than one operator according to certain rules of precedence. Expressions with more than one operator are evaluated in the following order:

  1. Terms inside parentheses: ( )
  2. Exponentiation: **
  3. Multiplication: *; Division: /; and Modulus: @
  4. Addition: +; Subtraction: -
  5. Equalities and Inequalities: =, <>, >, >=, <, <=
  6. NOT
  7. AND
  8. OR
  9. Concatenation: $; (For string expressions only.)

When evaluating more than one operator with the same precedence, ProModel works from left to right.

Arithmetic and boolean expressions may include nested expressions (expressions in parentheses) to indicate precedence in complex expressions such as the following examples:

 

Nested expressions

 

A+B*(C+D)

((A>B) OR (B>C)) AND (C>D)

The expression (C+D) is a nested expression which is evaluated first. Multiple nesting is permitted, with the innermost nesting being evaluated first.

Example 1

15 - MATRIX[4]**2 + CLOCK(MIN) / 60

In this expression, Matrix[4]**2 is evaluated first, with the result being subtracted from 15. This value is then added to the value obtained from Clock(min)/60.

Example 2

(A>B) OR (A>C) AND (A=D)

would evaluate

(A>B) OR ((A>C) AND (A=D))

 


© 2012 ProModel Corporation • 556 East Technology Avenue • Orem, UT 84097 • Support: 888-776-6633 • www.promodel.com